package com.app.activitys;

import java.util.ArrayList;
import java.util.List;

import com.app.activitys.adapters.SelectedAdapterVideos;
import com.app.entidades.Bandas;
import com.app.entidades.Videos;
import com.example.applucianokikao.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class VideoActiv extends Activity implements OnItemClickListener{

	private SelectedAdapterVideos selectedAdapterVideos;
	private ListView lista;
	private List<Videos> videos;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_videos);
		
		Bundle extras = getIntent().getExtras();
		Bundle valor = extras.getBundle("vid");
		videos= (List<Videos>) valor.getSerializable("videos");
		
		
		selectedAdapterVideos = new SelectedAdapterVideos(this,0,videos);
		lista = (ListView) findViewById(R.id.listVideos);
		lista.setAdapter(selectedAdapterVideos);
		lista.setOnItemClickListener((OnItemClickListener)this);
	
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		
		Intent intent = new Intent(VideoActiv.this, TelaVideo.class);	
		Videos video = (Videos)lista.getItemAtPosition(arg2);
		intent.putExtra("video", retornaChave(video.getLink()));
		startActivity(intent);
	}
	
	public String retornaChave(String link){
		String saida = "";
		String[] v = link.split("v=");
		saida = v[1];
		return saida;
	}

}
